package com.dx.controller;


import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dx.pojo.Title;
import com.dx.service.TitleService;

@Controller
public class TitleController {
	    @Resource
	    private TitleService titleService;
	    
	    @RequestMapping("/admin/inserttitle")
	    @ResponseBody
	    public String inserttitle(Title title){
	    	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
	    	title.setPublishingTime(sdf.format(new Date()));
	    	int n=titleService.inserttitle(title);
	    	if(n!=0){
	    		return "1";
	    	}else{
	    		return "0";
	    	}
	    }
	    
	    @RequestMapping("/user/querytitle")
	    @ResponseBody
	    public Title querytitle(){
	    	Title title=titleService.querttitle();
	    	return title;
	    }

}
